package com.hw.common.utils;

import cn.hutool.json.JSONObject;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @description
 */
public class HttpUtil {

    public static void writeJson(HttpServletResponse resp, JSONObject json) {
        PrintWriter out = null;
        try {
            resp.setContentType("application/json;charset=UTF-8");
            out = resp.getWriter();
            out.write(json.toJSONString(0));
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }

}
